<?php

namespace Modules\DataCheck\Enums\Tratis;

trait EnumExtend
{
    /**
     * @return array
     */
    public static function values(): array
    {
        return array_column(self::cases(), 'value');
    }

    /**
     * @param mixed $value
     * @return bool
     */
    public function equal(mixed $value): bool
    {
        return $this->value === $value || $this === $value;
    }

    /**
     * 获取枚举
     * @return array
     */
    public static function toArray(): array
    {
        $result = [];
        foreach (self::cases() as $case) {
            $result[$case->value] = $case->message();
        }
        return $result;
    }
}
